package yxy.cherry.battle.module.affix.skill;

import yxy.cherry.battle.Battle;
import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.module.affix.AffixContext.AffixAction;
import yxy.cherry.battle.module.affix.AffixContext.AffixActionClass;
import yxy.cherry.battle.module.affix.AffixFactory.SkillTypeEnum;
import yxy.cherry.battle.module.affix.Skill;
import yxy.cherry.battle.module.affix.SkillType;
import yxy.cherry.battle.module.record.stream.RecordStream42TriggerSkill;
import yxy.cherry.battle.module.record.stream.RecordStreamGroup;
import yxy.cherry.battle.module.record.stream.RecordStream_SKL;
import yxy.cherry.data.bean.skill;

import java.util.Collection;

/** 追攻 */
@SkillType(Type = SkillTypeEnum.追攻)
public class Affix_06_追攻 extends Skill {

	private int get伤害比例() {
		return getParam(0);
	}

	public Affix_06_追攻(Fighter actor, skill skilldata, int probability, int[] params) {
		super(actor, skilldata, probability, params);
	}

	private RecordStreamGroup steamGroup;

	@Override
	public RecordStreamGroup record() {
		steamGroup = getRecord().stream(new RecordStreamGroup());
		steamGroup.add(new RecordStream_SKL(getActor(), getSkillId()));
		return steamGroup;
	}

	@Override
	public boolean _exec(Collection<Fighter> targets) {
		if (getAffixContext().is附加行动中()) {
			return false;
		}
		if (!isEffectiveOne(getActor())) {
			return false;
		}
		boolean 有活人 = false;
		if (targets.size() <= 0) {
			for (Fighter target : getActor().getTeam().getTeam对手().getFighters()) {
				if (target.is活着()) {
					有活人 = true;
					break;
				}
			}
		} else {
			for (Fighter target : targets) {
				if (target.is活着()) {
					有活人 = true;
					break;
				}
			}
		}
		if (!有活人) {
			return false;
		}

		AffixAction action = getAffixContext().add附加行动(getActor(), targets, AffixActionClass.追加攻击);
		getRecord().stream(new RecordStream42TriggerSkill(getActor(),501)).record();
		action.set附加比例(get伤害比例());

		Battle.battleLogger(6,"追攻：追攻者："+getActor()+"伤害比例："+get伤害比例());

		return true;
	}

	@Override
	public boolean exec(Fighter actor, Fighter target) {
		return true;
	}

}